package com.dks.result;

import lombok.Getter;
import lombok.Setter;

/**
 * 结果信息：结果编码 + 结果信息
 * 结果编码：业务类型_编号(3位) eg: ERR_PAY_001 对应 支付相关业务的错误编码
 */
public enum ResultInfo {

    SUCCESS("ALL_SUCCESS", "执行成功！"),
    FAIL("ALL_FAIL", "执行失败！"),
    EXCEPTION("ALL_EXCEPTION", "执行异常"),
    SQ_EXCEPTION("SQ_EXCEPTION", "数据库执行异常"),
    WXPAY_FAIL("WXPAY_FAIL",""),

    ERR_BASE_001("ERR_BASE_001", "缺少请求参数："),

    ERR_NULL_TOKEN("TOKEN_IS_NULL", "token为空"),
    ERR_SEND_SMS("ERR_SEND_SMS", "发送短信异常"),
    ERR_DATA_STRUCTURE("ERR_DATA_STRUCTURE", "数据不存在"),
    ERR_BUSINESS_LIMIT_CONTROL("ERR_BUSINESS_LIMIT_CONTROL", "单位时间内短信发送已达上限"),
    NOT_REGISTER_WECHAT_CODE("NOT_REGISTER_WECHAT_CODE","该用户未注册，需要调用注册的逻辑(微信授权)"),
    ERR_PARAM_NULL("PARAM_IS_NULL","空指针异常"),

    /** 用户相关 */
    ERR_USERS_001("ERR_USERS_001", "未查询到用户信息"),
    ERR_USERS_002("ERR_USERS_002", "该用户不是新用户"),

    /** 评论回复相关 */
    ERR_COMMENT_001("ERR_COMMENT_001", "评论失败！"),
    ERR_COMMENT_002("ERR_COMMENT_002", "删除评论失败！"),
    ERR_COMMENT_003("ERR_COMMENT_003", "回复评论失败！"),
    ERR_COMMENT_004("ERR_COMMENT_004", "删除回复失败！"),

    /** 班级相关 */
    ERR_CLASS_001("ERR_CLASS_001", "未查询到班级详情"),

    /** 学生相关 */
    ERR_STUDENT_001("ERR_STUDENT_001", "提交作业失败"),
    ERR_STUDENT_002("ERR_STUDENT_002", "请假失败，超过次数限制："),
    ERR_STUDENT_003("ERR_STUDENT_003", "请假失败，请假提前时间限制，提前（小时）："),
    ERR_STUDENT_004("ERR_STUDENT_004", "请假失败"),
    ERR_STUDENT_005("ERR_STUDENT_005", "停课失败，"),
    ERR_STUDENT_CLASS_001("ERR_STUDENT_CLASS_001", "未查询课程记录"),
    ERR_STUDENT_CLASS_002("ERR_STUDENT_CLASS_002", "该堂课不是未签到状态"),
    ERR_STUDENT_CLASS_003("ERR_STUDENT_CLASS_003", "存在已经签到但是未确认的课程"),
    ERR_STUDENT_CLASS_004("ERR_STUDENT_CLASS_004", "剩余课程已经停课"),
    ERR_STUDENT_CLASS_005("ERR_STUDENT_CLASS_005", "停课失败"),

    /** 家长相关 */
    ERR_PARENT_001("ERR_PARENT_001","未查询到家长信息"),

    /** 约课相关 */
    ERR_APPOINT_CLASS_001("ERR_APPOINT_CLASS_001", "课程有变化，请刷新重试"),
    ERR_APPOINT_CLASS_002("ERR_APPOINT_CLASS_002", "剩余可用课时数不足"),
    ERR_APPOINT_CLASS_003("ERR_APPOINT_CLASS_003", "座位数不足"),
    ERR_APPOINT_CLASS_004("ERR_APPOINT_CLASS_004", "等位数不足"),
    ERR_APPOINT_CLASS_005("ERR_APPOINT_CLASS_005", "未查询到等位信息"),
    ERR_APPOINT_CLASS_006("ERR_APPOINT_CLASS_006", "本周取消次数超过限制"),
    ERR_APPOINT_CLASS_007("ERR_APPOINT_CLASS_007", "等位失败，请刷新重试"),
    ERR_APPOINT_CLASS_008("ERR_APPOINT_CLASS_008", "取消等位失败，请刷新重试"),
    ERR_APPOINT_CLASS_009("ERR_APPOINT_CLASS_009", "已经在等位队列，请刷新重试"),

    /** 课时包相关 */
    ERR_CLASS_HOUR_PACKAGE_001("ERR_CLASS_HOUR_PACKAGE_001","未查询到可用的课时包"),
    ERR_CLASS_HOUR_PACKAGE_002("ERR_CLASS_HOUR_PACKAGE_002","未查询到课时包"),
    ERR_CLASS_HOUR_PACKAGE_003("ERR_CLASS_HOUR_PACKAGE_003","课时包开通失败"),
    ERR_CLASS_HOUR_PACKAGE_004("ERR_CLASS_HOUR_PACKAGE_004","课时包转移失败"),
    ERR_CLASS_HOUR_PACKAGE_005("ERR_CLASS_HOUR_PACKAGE_005","课时包不能二次转移"),
    ERR_CLASS_HOUR_PACKAGE_006("ERR_CLASS_HOUR_PACKAGE_006","已超过课时包开卡时限"),
    ERR_CLASS_HOUR_PACKAGE_007("ERR_CLASS_HOUR_PACKAGE_007","当前课时包不可赠送"),

    /** 支付相关 */
    ERR_PAY_001("ERR_PAY_001","调用支付失败"),
    ERR_PAY_002("ERR_PAY_002","签名失败或者参数格式校验错误"),

    /** 优惠券相关 */
    ERR_CASH_COUPON_001("ERR_CASH_COUPON_001", "未查询到优惠券"),
    ERR_CASH_COUPON_002("ERR_CASH_COUPON_002", "优惠券有变化，请刷新重试"),




    ;


    // 成员变量
    @Getter
    private String code;
    @Setter
    @Getter
    private String message;
    // 构造方法
    ResultInfo(final String code, final String message) {
        this.code = code;
        this.message = message;
    }

    //根据code获取msg
    public static String getMsg(String code) {
        for (ResultInfo resultInfo : ResultInfo.values()) {
            if (resultInfo.code.equals(code)) {
                return resultInfo.message;
            }
        }
        return null;
    }


}
